package com.bdqn.serviceimpl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bdqn.component.ServerRespsone;
import com.bdqn.dao.BannerMapper;
import com.bdqn.dao.BarmenuMapper;
import com.bdqn.dao.FoodMapper;
import com.bdqn.entity.Banner;
import com.bdqn.entity.Barmenu;
import com.bdqn.entity.Food;
import com.bdqn.service.FoodService;
import com.bdqn.util.Page;

@Service("foodService")
public class FoodServiceImpl implements FoodService {

	@Autowired
	private  BannerMapper  bannerMapper;
	@Autowired
	private  BarmenuMapper  barmenuMapper;
	@Autowired  
	private   FoodMapper  foodMapper;
	
	
	@Override
	public List<Banner> getBannerByPostion(Integer id) {
		return bannerMapper.selectBannerByBarMenuId(id);
	}

	@Override
	public List<Barmenu> getBarmenus() {
		return barmenuMapper.selectAllBarmenu();
	}

	@Override
	public ServerRespsone getPageFood(Integer pageIndex, Integer pageSize, String foodName) {
		
		Map<String, Object>  params=new HashMap<String, Object>();
		params.put("foodName", foodName);
		int  count=foodMapper.selectCount(params);
		
		params.put("start", (pageIndex-1)*pageSize);
		params.put("row", pageSize);
		List<Food>  list=foodMapper.selelctFoods(params);
		Page<Food>  page=new Page<Food>(pageIndex, count, pageSize, list);
		return ServerRespsone.createSuccess("查询成功", page);
	}

}
